auto.waitFor();
function 随机数(minNum,maxNum) {
 
  switch(arguments.length){ 
      case 1: 
          return parseInt(Math.random()*minNum+1,10); 
      break; 
      case 2: 
          return parseInt(Math.random()*(maxNum-minNum+1)+minNum,10); 
      break; 
          default: 
              return 0; 
          break; 
  } 

}
function 随机数(minNum,maxNum) {
 
  switch(arguments.length){ 
      case 1: 
          return parseInt(Math.random()*minNum+1,10); 
      break; 
      case 2: 
          return parseInt(Math.random()*(maxNum-minNum+1)+minNum,10); 
      break; 
          default: 
              return 0; 
          break; 
  } 

}
启动抖音()
评论数组=global.WEB_PARAMS.commentgz.split('\n')
console.log(global.WEB_PARAMS)

for (var i=0;i<global.WEB_PARAMS.gznum;i++) {

  swipeUp();

  if (text('点击进入直播间').exists()) {
    continue;
  }
  if (text('广告').exists()) {
    continue;
  }
  sleep(随机数(5000,8000))
  sleep(2000);
 if ( like()){
  log('已点赞')

 }
 if ( subscribe()){
  log('已关注')

 }
 if ( comment()){
  log('已私信')

 }
 sleep(随机数(1000,5000))

}
toastLog('任务完成')
//点赞
function like () {
  var likeBtn = descContains('喜欢').visibleToUser().findOnce()


    likeBtn.click()
    sleep(2000);
    return true

}
//关注
function subscribe(){
  var subscribeBtn=descContains('关注').visibleToUser().findOnce()

    subscribeBtn.click()
    sleep(2000);
    return true

}

function comment(){
  
  var commentBtn=id('user_avatar').visibleToUser().findOnce()

    commentBtn.click()

    sleep(2000);
    desc('私信').findOne().click()
    sleep(2000);
    setText(评论数组[随机数(0,评论数组.length)]  )
    sleep(2000);
    desc('发送').findOne().click()
   back()
   sleep(2000);
   back()
   sleep(2000);
    return true

}